<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/static/htm/head" %>
<title>重置新密码</title>
<style type="text/css">
	#content {
		position:relative;
		width:70%;
		left:15%;
		top:10%;
	}
	#logo{
		text-align: center;
	}
	#head {
		font-size:15px;
	}
	table{
		border-color:#D4F2F2;
		border-width:1px;
		border-style:solid;
		font-size:15px;
	}
	tr {
		margin-top: 10px;
	}
</style>
</head>
<body>
	<div id="logo">
		<a href="index.jsp" title="游戏玩家论坛">
			<img alt="论坛Logo" height="56" src="static/pic/logo.jpg" width="192">
		</a>
	</div>
	 <div id="content">
	  		  <div id="head" style="float:right;">
				  <ul class="nav nav-pills">
			        <li  class="active"><a href="index.jsp">论坛主页</a></li>
			        <li><a href="login">登陆</a></li>
			        <li><a href="register">注册</a></li>
			      </ul>
		      </div>
		      <div id="body" style="clear:both;">
					<center>
					<form action="setpassword" method="post">
						<table class="well">
							<tr>
								<td>
									新密码
								</td>
								<td>
									<input type="password" name="pd1" id="passwd"/>
								</td>
								<td>
									 字母或数字组成，长度8~30
								</td>
							</tr>
							<tr>
								<td>
									确认密码
								</td>
								<td>
									<input type="password" name="pd2" id="confirm_passwd"/>
								</td>
								<td>
									重复输入密码
								</td>
							</tr>
							<tr id="error_div" style="visibility: ${visibility}">
								<td colspan="3">
			        					<div class="alert alert-error" id="error_info">
			        					${reason}
										</div>
								</td>
							</tr>
							<tr>
								<td></td>
								<td>
									<center><input type="submit" class="btn btn-success" id="submit" value="重置密码"></center>
								</td>
								<td></td>
							</tr>
						</table>
					</form>
					</center>
				</div>
			</div>
			   <%@ include file="/static/htm/foot.jsp" %>	
	</body>
	<script type="text/javascript">
		$(document).ready(function(){
			if($("#error_div").css("visibility") == "hidden") {
				$("#error_div").css("visibility","visible");
				$("#error_div").hide();
			}
			function checkPasswd() {
				var passwd = $("#passwd").val();
				var re = /[a-zA-Z0-9]{8,30}/;
				if(!re.test(passwd)) {
						$("#error_info").text("密码输入不正确。");
						$("#error_div").show();
					return false;
				}
				var confirm_passwd = $("#confirm_passwd").val();
				if(confirm_passwd != passwd) {
					$("#error_info").text("两次输入的密码不一致。");
					$("#error_div").show();
					return false;
				}
				return true;
			}
			$("#passwd").focus(function(){
				$("#error_div").hide();
			});
			$("#confirm_passwd").focus(function(){
				$("#error_div").hide();
			});
			$("#submit").click(function(){
				return checkPasswd();
			});
		});
	</script>
</html>